package servlet;

import bean.User;
import service.UserService;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @Author : liuchangling
 * @Descrition :
 * @Date： Created in 2:32 下午 2021/5/30
 */
@WebServlet(name = "SelectUserServlet",urlPatterns = "/GetUserBySno")
public class SelectUserServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String s=request.getParameter("sno").trim();
        System.out.println(s);
        int sno=Integer.parseInt(s);
        UserService userService=new UserService();
        List<User> list= userService.getUserBySno(sno);
        System.out.println(list.toString());
        request.getSession().setAttribute("result", list);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request,response);
    }
}
